package com.leilei.greendao.db;

import android.content.Context;
import android.util.Log;

import com.leilei.greendao.greendao.DaoMaster;
import com.leilei.greendao.greendao.PersonDao;
import com.leilei.greendao.greendao.SonDao;

import org.greenrobot.greendao.database.Database;

/**
 * Created by leilei on 2018/1/27.
 */

public class GreenDaoHelp extends DaoMaster.OpenHelper {

    public static final String DATA_BASE_NAME = "leilei-db";


    public GreenDaoHelp(Context context) {
        super(context, DATA_BASE_NAME, null);
    }

    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {
        super.onUpgrade(db, oldVersion, newVersion);
        Log.e("version000", oldVersion + "---先前和更新之后的版本---" + newVersion);
        if (oldVersion < newVersion) {
            MigrationHelper.migrate(db, PersonDao.class, SonDao.class);
        }
    }
}
